$(document).ready ->
  $('.project_destroy').click (e)->
    e.preventDefault()
    if confirm_data = $(this).data('confirm')
      return unless window.confirm( confirm_data )
      
    $.post $(this).data('uri'), (data)=>
      Alert.doit data, =>
        $(this).parents('tr').hide()

  $('.projectsort input').blur (e) ->
    upForm = $('#'+$(this).data('formid'))
    $.ajax
      url: upForm.attr('action')
      type: 'POST',
      data: upForm.serialize()
      success: (res)->
        show('保存成功！');
      error: (res)->
        show('保存失败！');

  $('.message_update').click (e)->
    e.preventDefault()
    if confirm_data = $(this).data('confirm')
      return unless window.confirm( confirm_data )
      
    $.post $(this).data('uri'), (data)=>
      Alert.doit data, =>
        alert(data.message)
        location.reload()

  $('.message_destroy').click (e)->
    e.preventDefault()
    if confirm_data = $(this).data('confirm')
      return unless window.confirm( confirm_data )
      
    $.post $(this).data('uri'), (data)=>
      Alert.doit data, =>
        alert(data.message)
        $(this).parents('tr').hide()